<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<s:include value="common/header.jsp"></s:include>
	<link type="text/css" rel="stylesheet" href="css/jquery.realperson.css">
	<script type="text/javascript" src="js/lib/jquery.realperson.js"></script>
</head>
<script type="text/javascript">
	$(function() {
		var code = '';
// 		$('#submit').click(function() {
// 			$.post('json/login!queryUser.do', function(json){
// 				$('#fromTitle').append('測試文件列表');
// 				var table = $('#from');
// 				$('<td>編號</td><td>姓名</td><td>電話</td>').appendTo(table);
// 				$.each(json.data.userList, function(i, o) {
// 					var tr = $('<tr></tr>').appendTo(table);
// 					var td = $('<td></td>');
// 					var td2 = $('<td></td>');
// 					var td3 = $('<td></td>');
// 					td.append(o.id).appendTo(tr);
// 					td2.append(o.neme).appendTo(tr);
// 					td3.append(o.phone).appendTo(tr);
// 				}); 
// 			}, 'json');
// 		});
		$('#submit').button().click(function() {
			
// 			if($('#sign').val() == '' || $('#password').val() == '') {
// 				return false;
// 			}
			$('#loginFrom').submit();
		});
		
		//test
		var table = $('#validate');
		var string =['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
		for(var i=0; i<6; i++) {
			var o = Math.floor(Math.random()*(37-0));
			code += string[o];
		}
		var tr = $('<tr></tr>').appendTo(table);
		$('<td style="background-color:rgb(15,99,30)"></td>').append(code).appendTo(tr);
		
		$('#test').click(function() {
			$.post('json/login!validateUser.do', {'param.code':code}, function(){});
		});
		
		//testList
		var div = $('#testList');
		for(i=0;i<10;i++) {
			$('<input class="mailCheckbox" type="checkbox" value="'+i+'"/>').appendTo(div);
		}
		
		var mailSendId= [];
		$('.mailCheckbox').click(function() {
			if($(this).attr('checked')) {
				mailSendId[mailSendId.length] = [this.value];
			}else {
				var value = this.value;
				mailSendId = $.grep(mailSendId, function(v) {
					return v != value;
				});
			};
		});
		
		$('#testPost').click(function() {
			console.log(mailSendId);
			$.post('json/login!testList.do', {'testList':mailSendId, 'testList2':mailSendId}, function(obj) {
				console.log(obj);
			}, 'json');
		});
	});
</script>
<body>
	<s:form id="loginFrom" action="login!validateUser.do" method="post">
		<input id="sign" name="param.signId" type="text">
		<input id="password" name="param.password" type="text">
		<button id="submit">送出</button>
	</s:form>
	<div id="fromTitle"></div>
	<table id="from"></table>
	<table id="validate"></table>
	<button id="test">測試</button>
	<div id="testList">
	</div>
	<button id="testPost">testPost</button>
</body>
</html>